package com.yxkj.syh.app.huarong.activities.orders.detail.status_other;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.syh.app.basic.base.BaseActivity;
import com.syh.app.basic.utils.AppUtil;
import com.syh.app.basic.utils.ComUtil;
import com.syh.app.basic.utils.Tooast;
import com.syh.app.basic.views.ImageWatcher;
import com.yxkj.syh.app.huarong.BR;
import com.yxkj.syh.app.huarong.R;
import com.yxkj.syh.app.huarong.bean.CheckInfo;
import com.yxkj.syh.app.huarong.bean.Goods;
import com.yxkj.syh.app.huarong.bean.OrderDetail;
import com.yxkj.syh.app.huarong.bean.OrderInfo;
import com.yxkj.syh.app.huarong.bean.UserMainInfo;
import com.yxkj.syh.app.huarong.constants.ArouterPath;
import com.yxkj.syh.app.huarong.constants.OrderStatus;
import com.yxkj.syh.app.huarong.databinding.ActivityOrderOtherStatusBinding;

@Route(path = ArouterPath.ORDER_OTHER_STATUS_ACTIVITY)
public class OrderOtherStatusActivity extends BaseActivity<ActivityOrderOtherStatusBinding, OrderOtherStatusVM> {

    @Autowired
    long orderId;

    @Override
    protected int getContentLayout() {
        return R.layout.activity_order_other_status;
    }

    @Override
    protected int getViewModelId() {
        return BR.orderOtherStatusVM;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    @Override
    protected void initData() {
        mViewModel.getOrderDetail(orderId);
    }

    @Override
    protected void initObservers() {
        super.initObservers();
        mViewModel.mldOrderDetail.observe(this, orderDetail -> {
            initOrderDetail(orderDetail);
        });

        mVDBinding.titleView.setLeftOnClickListener(v -> finish());
        mViewModel.mldClear7.observe(this, aBoolean -> {
            if (aBoolean) finish();
        });
    }

    private void initOrderDetail(OrderDetail orderDetail) {
        OrderInfo orderInfo = orderDetail.getOrderInfo();

        switch (orderInfo.getStatus()) {
            case OrderStatus.WAIT_ECEIVING:
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#FFFBD4"));
                mVDBinding.tvStatus.setText("待收货");
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.defaultOrange));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                if (orderInfo.getFlag() == 1) {//驳回
                    setCheckInfo(orderInfo);
                    setOrderReturn();//待定价驳回
                }
                setOrder(orderInfo);
                break;
            case OrderStatus.WAIT_PRICING:
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#FFFBD4"));
                mVDBinding.tvStatus.setText("待定价");
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.defaultOrange));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                setCheckInfo(orderInfo);
                if (orderInfo.getFlag() == 1) {//驳回
                    setPriceInfo(orderInfo);
                    setOrderReturn();//待核算驳回
                }
                setOrder(orderInfo);
                break;
            case OrderStatus.WAIT_ADJUST://待核算
            case OrderStatus.IN_APPROVAL://待审批
                mVDBinding.tvStatus.setText("待核算");
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#FFFBD4"));
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.defaultOrange));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                setCheckInfo(orderInfo);
                setPriceInfo(orderInfo);
                setOrder(orderInfo);
                break;
            case OrderStatus.WAIT_PAYMENT://待结算
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#FFFBD4"));
                mVDBinding.tvStatus.setText("待结算");
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.defaultOrange));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                setCheckInfo(orderInfo);
                setPriceInfo(orderInfo);
                setMoneyCheck();
                setOrder(orderInfo);
                break;
            case OrderStatus.COMPLETED:
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#E4FFF5"));
                mVDBinding.tvStatus.setText("已完成");
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.defaultGreen));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                setCheckInfo(orderInfo);
                setPriceInfo(orderInfo);
                setMoneyCheck();
                setMoneyChecked(orderInfo);
                setOrder(orderInfo);
                break;
            case OrderStatus.CANCELED:
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#DBDFE1"));
                mVDBinding.tvStatus.setText("已取消");
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.textColor4));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                setOrder(orderInfo);
                break;
            case OrderStatus.RETURN:
                mVDBinding.flStatus.setBackgroundColor(Color.parseColor("#FFFBD4"));
                mVDBinding.tvStatus.setText("全部退货");
                mVDBinding.tvStatus.setTextColor(ContextCompat.getColor(this, R.color.defaultOrange));
                setFromAndTo(orderInfo.getStartLocation(), orderInfo.getEndLocation());
                setPurInfo(orderInfo);
                setGoodsReturn(orderInfo);
                setOrder(orderInfo);
                setClear7(orderInfo);
                break;
        }

        mVDBinding.llContent.requestLayout();

    }


    /**
     * 收发
     */
    private void setFromAndTo(UserMainInfo from, UserMainInfo to) {
        View view = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_from_and_to, null);
        TextView tvFromPerson = view.findViewById(R.id.tvFromPerson);
        TextView tvFromMobile = view.findViewById(R.id.tvFromMobile);
        TextView tvFromAddress = view.findViewById(R.id.tvFromAddress);
        TextView tvToPerson = view.findViewById(R.id.tvToPerson);
        TextView tvToMobile = view.findViewById(R.id.tvToMobile);
        TextView tvToAddress = view.findViewById(R.id.tvToAddress);
        tvFromPerson.setText(from.getLinkman());
        tvFromMobile.setText(from.getMobile());
        tvFromAddress.setText(from.getArea().replace("/","") + from.getAddress());
        tvToPerson.setText(to.getLinkman());
        tvToMobile.setText(to.getMobile());
        tvToAddress.setText(to.getArea().replace("/","") + to.getAddress());

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
        mVDBinding.llContent.addView(view, params);
        view.requestLayout();

    }

    /**
     * 采购信息
     */
    private void setPurInfo(OrderInfo orderInfo) {

        LinearLayout viewPur = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.activity_order_detail_part_pur_info, null);
        TextView tvSupplier = viewPur.findViewById(R.id.tvSupplier);
        TextView tvBuyer = viewPur.findViewById(R.id.tvBuyer);
        TextView tvFactory = viewPur.findViewById(R.id.tvFactory);
        tvSupplier.setText(orderInfo.getSupplierName());
        tvBuyer.setText(orderInfo.getSalesman().getRealName());
        tvFactory.setText(orderInfo.getEndLocation().getName());

        //货品
        for (Goods temp : orderInfo.getDetails()) {
            View view = LayoutInflater.from(this).inflate(R.layout.view_order_goods, null);
            TextView tvName = view.findViewById(R.id.tvName);
            TextView tvCount = view.findViewById(R.id.tvCount);
            tvName.setText(temp.getName());
            tvCount.setText(temp.getPackages() + "包，" + ComUtil.clearNoUseZero(temp.getQuantity()).toPlainString() + "吨");
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            viewPur.addView(view, params);
            view.requestLayout();
        }

        //车牌
        if (orderInfo.getStatus() != OrderStatus.CANCELED) {
            View view = LayoutInflater.from(this).inflate(R.layout.view_car_id, null);
            TextView tvCarId = view.findViewById(R.id.tvCarId);
            TextView tvRemark = view.findViewById(R.id.tvRemark);
            tvCarId.setText(mViewModel.getLogExtendJson("license", 1, 1));
            tvRemark.setText(mViewModel.getLogMsg(1,1));
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            viewPur.addView(view, params);
            view.requestLayout();
        }

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(viewPur, params1);
        viewPur.requestLayout();

    }

    /**
     * 订单信息
     */
    private void setOrder(OrderInfo orderInfo) {
        View orderView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_order_info, null);

        TextView tvOrderId = orderView.findViewById(R.id.tvOrderId);
        TextView tvCreatTime = orderView.findViewById(R.id.tvCreatTime);
        TextView tvCancelTime = orderView.findViewById(R.id.tvCancelTime);
        TextView tvSendTime = orderView.findViewById(R.id.tvSendTime);
        TextView tvReceiptTime = orderView.findViewById(R.id.tvReceiptTime);
        TextView tvPriceTime = orderView.findViewById(R.id.tvPriceTime);
        TextView tvPayTime = orderView.findViewById(R.id.tvPayTime);
        TextView tvReturnTime = orderView.findViewById(R.id.tvReturnTime);
        TextView tvMoneyCheckTime = orderView.findViewById(R.id.tvMoneyCheckTime);

        tvOrderId.setText(orderInfo.getNo());
        tvCreatTime.setText(orderInfo.getCreateTime());
        tvCancelTime.setText(mViewModel.getOrderTime(OrderStatus.CANCELED));
        tvSendTime.setText(mViewModel.getOrderTime(OrderStatus.WAIT_ECEIVING));
        tvReceiptTime.setText(mViewModel.getOrderTime(OrderStatus.WAIT_PRICING));
        tvPriceTime.setText(mViewModel.getOrderTime(OrderStatus.WAIT_ADJUST));
        tvPayTime.setText(mViewModel.getOrderTime(OrderStatus.COMPLETED));
        tvMoneyCheckTime.setText(mViewModel.getOrderTime(OrderStatus.WAIT_PAYMENT));
        tvReturnTime.setText(mViewModel.getOrderTime(OrderStatus.RETURN));

        orderView.findViewById(R.id.tvCopyID).setOnClickListener(v -> {
            if (AppUtil.copy2Clipboard(OrderOtherStatusActivity.this, orderInfo.getNo())) {
                Tooast.success("已复制订单编号到粘贴板");
            }
        });

        orderView.findViewById(R.id.ivQrCode).setOnClickListener(v -> {
            Bitmap bitmap = ComUtil.createQRCode(orderInfo.getNo(), 400);
            new ImageWatcher(OrderOtherStatusActivity.this).show(bitmap);
        });

        FrameLayout flCancelTime = orderView.findViewById(R.id.flCancelTime);
        FrameLayout flSendTime = orderView.findViewById(R.id.flSendTime);
        FrameLayout flReceiptTime = orderView.findViewById(R.id.flReceiptTime);
        FrameLayout flPriceTime = orderView.findViewById(R.id.flPriceTime);
        FrameLayout flPayTime = orderView.findViewById(R.id.flPayTime);
        FrameLayout flReturnTime = orderView.findViewById(R.id.flReturnTime);
        FrameLayout flMoneyCheckTime = orderView.findViewById(R.id.flMoneyCheckTime);

        //是否显示
        switch (orderInfo.getStatus()) {
            case OrderStatus.WAIT_ECEIVING:
                flSendTime.setVisibility(View.VISIBLE);
                if (orderInfo.getFlag() == 1) {//待定价驳回
                    flReceiptTime.setVisibility(View.VISIBLE);
                }
                break;
            case OrderStatus.WAIT_PRICING:
                flSendTime.setVisibility(View.VISIBLE);
                flReceiptTime.setVisibility(View.VISIBLE);
                break;
            case OrderStatus.WAIT_ADJUST://待核算
            case OrderStatus.IN_APPROVAL://待审批
            case OrderStatus.WAIT_PAYMENT://待结算
                flSendTime.setVisibility(View.VISIBLE);
                flReceiptTime.setVisibility(View.VISIBLE);
                flPriceTime.setVisibility(View.VISIBLE);
                break;
            case OrderStatus.COMPLETED:
                flSendTime.setVisibility(View.VISIBLE);
                flReceiptTime.setVisibility(View.VISIBLE);
                flPriceTime.setVisibility(View.VISIBLE);
                flPayTime.setVisibility(View.VISIBLE);
                flMoneyCheckTime.setVisibility(View.VISIBLE);
                break;
            case OrderStatus.CANCELED:
                flCancelTime.setVisibility(View.VISIBLE);
                break;
            case OrderStatus.RETURN:
                flReturnTime.setVisibility(View.VISIBLE);
                flSendTime.setVisibility(View.VISIBLE);
                break;
        }

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(orderView, params1);
        orderView.requestLayout();


    }

    /**
     * 验收信息
     */
    private void setCheckInfo(OrderInfo orderInfo) {
        CheckInfo checkInfo = mViewModel.getCheckInfo();
        if (checkInfo != null) {
            View checkView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_check_info, null);

            //部分退货
            if (orderInfo.getStatus() == OrderStatus.WAIT_PRICING || orderInfo.getStatus() == OrderStatus.WAIT_ECEIVING) {
                String type = mViewModel.getLogExtendJson("type", 2, 1);
                if (!TextUtils.isEmpty(type) && type.equals("1")) {
                    TextView tvDes = checkView.findViewById(R.id.tvDes);
                    tvDes.setText("部分退货");
                    tvDes.setVisibility(View.VISIBLE);
                }
            }

            //货品
            LinearLayout llGoods = checkView.findViewById(R.id.llGoods);
            for (Goods temp : orderInfo.getDetails()) {
                View view = LayoutInflater.from(this).inflate(R.layout.view_order_goods_check_info, null);
                TextView tvName = view.findViewById(R.id.tvName);
                TextView tvCount = view.findViewById(R.id.tvCount);
                TextView tvkou = view.findViewById(R.id.tvkou);
                TextView tvkouQ = view.findViewById(R.id.tvkouQ);
                TextView tvSQ = view.findViewById(R.id.tvSQ);
                tvName.setText(temp.getName());
                tvCount.setText("实际验收" + temp.getPackages() + "包，" + ComUtil.clearNoUseZero(temp.getQuantity()).toPlainString() + "吨");
                tvkou.setText(ComUtil.clearNoUseZero(temp.getDeduct()).toPlainString()+"%");
                tvkouQ.setText(ComUtil.clearNoUseZero(temp.getDeductQuantity()).toPlainString());
                tvSQ.setText(ComUtil.clearNoUseZero(temp.getSettleQuantity()).toPlainString());

                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                llGoods.addView(view, params);
                view.requestLayout();
            }

            //回执单
            ImageView ivReceipt = checkView.findViewById(R.id.ivReceipt);
            Glide.with(this).load(checkInfo.getReceipt()).apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
                    .into(ivReceipt);
            ivReceipt.setOnClickListener(v -> {
                new ImageWatcher(OrderOtherStatusActivity.this).show(checkInfo.getReceipt());
            });
//
//            TextView tvAll = checkView.findViewById(R.id.tvAll);
//            TextView tvShuiFen = checkView.findViewById(R.id.tvShuiFen);
//            TextView tvZaZhi = checkView.findViewById(R.id.tvZaZhi);
//            TextView tvZaPaper = checkView.findViewById(R.id.tvZaPaper);
//            TextView tvOther = checkView.findViewById(R.id.tvOther);
//
//            tvAll.setText(checkInfo.getDeductQuantity().toPlainString() + "吨");
//            tvShuiFen.setText(checkInfo.getWaterQuantity().toPlainString() + "吨");
//            tvZaZhi.setText(checkInfo.getImpurityQuantity().toPlainString() + "吨");
//            tvZaPaper.setText(checkInfo.getDiscardQuantity().toPlainString() + "吨");
//            tvOther.setText(checkInfo.getOtherQuantity().toPlainString() + "吨");

            //凭证
            LinearLayout llCertificates = checkView.findViewById(R.id.llCertificates);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ComUtil.Dp2Px(this, 70), ComUtil.Dp2Px(this, 70));
            params.rightMargin = ComUtil.Dp2Px(this, 10);
            if (checkInfo.getCertificates() != null) {
                int size = checkInfo.getCertificates().size() > 6 ? 6 : checkInfo.getCertificates().size();
                for (int i = 0; i < size; i++) {
                    ImageView iv = new ImageView(this);

                    String url = checkInfo.getCertificates().get(i);
                    Glide.with(this).load(url).apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
                            .into(iv);
                    llCertificates.addView(iv, params);
                    iv.requestLayout();
                    iv.setOnClickListener(v -> new ImageWatcher(OrderOtherStatusActivity.this).show(url));
                }
            }

            //验收描述
            String desMsg = mViewModel.getLogMsg(2, 1);
            if (TextUtils.isEmpty(desMsg)) {
                LinearLayout llCheckInfoDes = checkView.findViewById(R.id.llCheckInfoDes);
                llCheckInfoDes.setVisibility(View.GONE);
            } else {
                TextView tvCheckInfoDes = checkView.findViewById(R.id.tvCheckInfoDes);
                tvCheckInfoDes.setText(desMsg);
            }

            LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
            params1.topMargin = ComUtil.Dp2Px(this, 10);
            mVDBinding.llContent.addView(checkView, params1);
            checkView.requestLayout();

        }
    }

    /**
     * 定价信息
     */
    private void setPriceInfo(OrderInfo orderInfo) {
        View priceView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_price_info, null);


        LinearLayout llGoods = priceView.findViewById(R.id.llGoods);
        LinearLayout.LayoutParams goodsParam = new LinearLayout.LayoutParams(-1, -2);
        for (Goods goods : orderInfo.getDetails()) {
            View tempView = LayoutInflater.from(this).inflate(R.layout.view_price_confirm, null);
            TextView tvName = tempView.findViewById(R.id.tvName);
            TextView tvPrice = tempView.findViewById(R.id.tvPrice);
            TextView tvPriceCount = tempView.findViewById(R.id.tvPriceCount);
            tvName.setText(goods.getName());
            tvPrice.setText(goods.getPrice().toPlainString() + "元/吨");
            tvPriceCount.setText(goods.getSettleMoney() + "元");
            llGoods.addView(tempView, goodsParam);
            tempView.requestLayout();

        }

        TextView tvAllGoodsCount = priceView.findViewById(R.id.tvAllGoodsCount);
        String actualAmount = mViewModel.getLogExtendJson("paymentAmount",3,1);
        if (TextUtils.isEmpty(actualAmount)){
            actualAmount = mViewModel.getLogExtendJson("actualAmount",3,1);
        }
        tvAllGoodsCount.setText(actualAmount + "元");


        //定价描述
        String desMsg = mViewModel.getLogMsg(3, 1);
        if (TextUtils.isEmpty(desMsg)) {
            LinearLayout flCheckInfoDes = priceView.findViewById(R.id.flCheckInfoDes);
            flCheckInfoDes.setVisibility(View.GONE);
        } else {
            TextView tvPriceInfoDes = priceView.findViewById(R.id.tvPriceInfoDes);
            tvPriceInfoDes.setText(desMsg);
        }


        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(priceView, params1);
        priceView.requestLayout();

    }

    /**
     * 核对信息
     */
    private void setMoneyCheck() {
        View moneyCheckView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_part_money_check, null);

        TextView tvCheckMoney = moneyCheckView.findViewById(R.id.tvCheckMoney);
        TextView tvDes = moneyCheckView.findViewById(R.id.tvDes);
        tvCheckMoney.setText(mViewModel.getLogExtendJson("actualAmount", 4, 1) + "元");
        tvDes.setText(mViewModel.getLogMsg(4, 1));
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) tvDes.getLayoutParams();
        layoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
        tvDes.requestLayout();

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(moneyCheckView, params1);
        moneyCheckView.requestLayout();
    }

    /**
     * 结算信息
     */
    private void setMoneyChecked(OrderInfo orderInfo) {
        View moneyCheckedView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_part_money_checked, null);

        TextView tvCheckedMoney = moneyCheckedView.findViewById(R.id.tvCheckedMoney);
        TextView tvPayedMoney = moneyCheckedView.findViewById(R.id.tvPayedMoney);
        ImageView ivChecked = moneyCheckedView.findViewById(R.id.ivChecked);
        TextView tvDes = moneyCheckedView.findViewById(R.id.tvDes);
        String actualAmount = mViewModel.getLogExtendJson("actualAmount", 5, 1);
        String paymentAmount = mViewModel.getLogExtendJson("paymentAmount", 5, 1);
        if (TextUtils.isEmpty(actualAmount)){
            actualAmount = mViewModel.getLogExtendJson("actualAmount", 4, 1);
        }

        tvCheckedMoney.setText(actualAmount + "元");
        tvPayedMoney.setText(paymentAmount + "元");

        String url = mViewModel.getLogExtendJson("certificate", 5, 1);
        Glide.with(this).load(url).apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
                .into(ivChecked);
        if (!TextUtils.isEmpty(url)){
            ivChecked.setOnClickListener(v -> new ImageWatcher(OrderOtherStatusActivity.this).show(url));
        }
        tvDes.setText(mViewModel.getLogMsg(5, 1));

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(moneyCheckedView, params1);
        moneyCheckedView.requestLayout();
    }

    /**
     * 驳回信息
     */
    private void setOrderReturn() {
        View returnView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_part_order_return, null);

        TextView tvReason = returnView.findViewById(R.id.tvReason);
        tvReason.setText(mViewModel.getLogMsg(-4, 1));

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(returnView, params1);
        returnView.requestLayout();
    }

    /**
     * 退货信息
     */
    private void setGoodsReturn(OrderInfo orderInfo) {
        View returnView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_goods_return, null);

        //货品
        LinearLayout llGoods = returnView.findViewById(R.id.llGoods);
        for (Goods temp : orderInfo.getDetails()) {
            View view = LayoutInflater.from(this).inflate(R.layout.view_order_goods, null);
            TextView tvName = view.findViewById(R.id.tvName);
            TextView tvCount = view.findViewById(R.id.tvCount);
            tvName.setText(temp.getName());
            tvCount.setText("全部退货");
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            llGoods.addView(view, params);
            view.requestLayout();
        }

        TextView tvReturnDes = returnView.findViewById(R.id.tvReturnDes);
        tvReturnDes.setText(mViewModel.getLogMsg(7, 1));

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(returnView, params1);
        returnView.requestLayout();
    }
    /**
     * 回收退货单
     */
    private void setClear7(OrderInfo orderInfo) {
        View returnView = LayoutInflater.from(this).inflate(R.layout.activity_order_detail_clear_status7, null);

        Button btnClear = returnView.findViewById(R.id.btnClear);
        btnClear.setOnClickListener(v -> {
            mViewModel.clearStatus7(orderInfo.getId());
        });

        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(-1, -2);
        params1.topMargin = ComUtil.Dp2Px(this, 10);
        mVDBinding.llContent.addView(returnView, params1);
        returnView.requestLayout();
    }

}
